﻿Public Class frequentcustomer
    Dim item As ListViewItem
    Sub listdata()
        If Not rs.EOF Then
            ListView1.Items.Clear()
            rs.MoveFirst()
            Do While Not rs.EOF
                item = ListView1.Items.Add(rs.Fields("CustomerNo").Value)
                item.SubItems.Add(rs.Fields("Name1").Value)
                item.SubItems.Add(rs.Fields("count1").Value)


                rs.MoveNext()

            Loop
        Else
            ListView1.Items.Clear()

        End If
        rs.Close()
        rs = Nothing

    End Sub
    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click

    End Sub

    Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged

    End Sub

    Private Sub frequentcustomer_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Module1.connect()
        rs = New ADODB.Recordset
        rs.Open("SELECT customerno, name1, sum(nooftimes) AS count1 FROM Query1 WHERE month(date1) = " & TextBox1.Text & " and year(date1) = " & TextBox2.Text & " group by customerno, name1 order by 3 desc", cn, 3, 2)
        Me.listdata()
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        report.Show()
        Me.Hide()

    End Sub

    Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label3.Click

    End Sub
End Class